import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity("device", { schema: "charge" })
export class Device {
  @PrimaryGeneratedColumn({ type: "int", name: "id", unsigned: true })
  id: number;

  @Column("varchar", { name: "name", length: 100 })
  name: string;

  @Column("int", {
    name: "device_type_id",
    comment: "类型",
    default: () => "'0'",
  })
  deviceTypeId: number;

  @Column("int", {
    name: "total_water_usage",
    comment: "总用水量",
    unsigned: true,
    default: () => "'0'",
  })
  totalWaterUsage: number;

  @Column("json", { name: "port_data", nullable: true, comment: "端口数据" })
  portData: object | null;

  @Column("tinyint", {
    name: "connect_status",
    comment: "链接状态1：是，0：否",
    default: () => "'0'",
  })
  connectStatus: number;

  @Column("int", {
    name: "online_time",
    comment: "上线时间",
    unsigned: true,
    default: () => "'0'",
  })
  onlineTime: number;

  @Column("int", {
    name: "offline_time",
    comment: "离线时间",
    unsigned: true,
    default: () => "'0'",
  })
  offlineTime: number;

  @Column("boolean", {
    name: "at_ali",
    comment: "是否已经注册到阿里云"
  })
  atAli: boolean;

  @Column("char", { name: "ali_id", comment: "阿里云的设备id", length: 32 })
  aliId: string;

  @Column("char", {
    name: "ali_secret",
    comment: "阿里云的设备Secret",
    length: 32,
  })
  aliSecret: string;

  @Column("int", { name: "merchant_id", unsigned: true, default: () => "'0'" })
  merchantId: number;

  @Column("int", {
    name: "station_id",
    comment: "站点id",
    unsigned: true,
    default: () => "'0'",
  })
  stationId: number;

  @Column("int", { name: "user_id", unsigned: true, default: () => "'0'" })
  userId: number;

  @Column("char", { name: "sim", comment: "物联网卡", length: 20 })
  sim: string;

  @Column("varchar", { name: "hardware", comment: "硬件", length: 30 })
  hardware: string;

  @Column("varchar", { name: "software", comment: "软件", length: 30 })
  software: string;

  @Column("tinyint", {
    name: "signal",
    comment: "信号强度",
    unsigned: true,
    default: () => "'0'",
  })
  signal: number;

  @Column("varchar", { name: "remark", length: 100 })
  remark: string;

  @Column("boolean", {
    name: "is_private",
    comment: "1：私人的"
  })
  isPrivate: boolean;

  @Column("boolean", { name: "enable"})
  enable: boolean;

  @Column("int", {
    name: "creator_id",
    comment: "创建人",
    unsigned: true,
    default: () => "'0'",
  })
  creatorId: number;

  @Column("int", { name: "create_time", unsigned: true, default: () => "'0'" })
  createTime: number;

  @Column("int", { name: "update_time", unsigned: true, default: () => "'0'" })
  updateTime: number;
}
